package cn.gz.demo.adapter;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

import cn.gz.demo.R;
import cn.gz.demo.bean.Product;
import cn.gz.demo.databinding.AdapterLeftListBinding;

/**
 * Created by fangzhu on 2015/4/23.
 */
public class LeftAdapter extends RecyclerView.Adapter<LeftAdapter.MyViewHolder> {
    private Activity context;
    private List<Product> list;

    public LeftAdapter(Activity activity, List<Product> response) {
        this.context = activity;
        this.list = response;
    }


    @Override
    public LeftAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_left, parent, false);
        return new LeftAdapter.MyViewHolder(view);
    }

    @Override
    public void onBindViewHolder(LeftAdapter.MyViewHolder holder, int position) {
        final Product bean = list.get(position);
        holder.binding.left.tvItem.setText(bean.getName() + "");

    }

    @Override
    public int getItemCount() {
        return list == null ? 0 : list.size();
    }

    public class MyViewHolder extends RecyclerView.ViewHolder {
        private AdapterLeftListBinding binding;

        public MyViewHolder(View view) {
            super(view);
            binding = DataBindingUtil.bind(view);
        }
    }
}